package net.ys.controller;

import net.ys.bean.SwAlarm;
import net.ys.service.ApiService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

/**
 * @author: NMY
 * @Date: 2021/7/7
 * @Time: 13:16
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @Resource
    private ApiService apiService;

    /**
     * 钉钉 / yearning
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/ding")
    public Object dingTalk(HttpServletRequest request) throws Exception {
        return apiService.dingTalk(request);
    }

    /**
     * 企业微信/ yearning
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping("/wx")
    public Object wx(HttpServletRequest request) throws Exception {
        return apiService.wx(request);
    }

    /**
     * 企业微信/prometheus
     *
     * @param request
     * @return
     * @throws IOException
     */
    @RequestMapping("/prom")
    public Object prom(HttpServletRequest request) throws IOException {
        return apiService.prom(request);
    }

    /**
     * 企业微信/sky walking
     *
     * @return
     */
    @RequestMapping("/wx/sky")
    public Object sky(@RequestBody List<SwAlarm> alarmList) {
        return apiService.sky(alarmList);
    }
}
